<?php

namespace Acme\Likipe\BlogBundle\Controller;

use Symfony\Component\HttpFoundation\Request;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Acme\Likipe\BlogBundle\Repository;

use Symfony\Component\HttpFoundation\RedirectResponse;

// Form
use Acme\Likipe\BlogBundle\Form\BlogType;

// Entity
use Acme\Likipe\BlogBundle\Entity\Blog;


class DefaultController extends Controller
{
    
    public function indexAction()
    {
    	$this->get( 'session' )
    		->setFlash( 'menu', '1' );
    	
    	$oEm = $this->getDoctrine()->getEntityManager();
    	$oBlogs = $oEm->getRepository( 'AcmeLikipeBlogBundle:Blog' )
    		->findAll();
    	
    	if ($oBlogs == null){
    		$this->get( 'session' )->setFlash( 'warning', 'No Blog found!' );
    	}
    	
        return $this->render( 'AcmeLikipeBlogBundle:Homepage:index.html.twig', 
        		array( 'blogs' => $oBlogs ));
    }
}
